import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionListener;

import javax.swing.JList;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.AbstractListModel;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
/**
 * This class is the view for the Status
 * @author Sravya
 *
 */
public class StatusView extends JPanel {

        private JPanel contentPane;
        private StatusModel sm; 
        private JButton ok;
        private JComboBox cb;
        private JComboBox cb2;
        
        
        /**
         * This constructor creates the frame.
         */
        public StatusView(StatusModel sm) {
                this.sm = sm;
                
                //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                setSize(300, 290);
                //contentPane = new JPanel();
                setBackground(new Color(218, 165, 32));
                //contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                //setContentPane(contentPane);
                
                JLabel lblRations = new JLabel("Rations:");
                lblRations.setFont(new Font("Tahoma", Font.BOLD, 12));
                
                JLabel lblPace = new JLabel("Pace:");
                lblPace.setFont(new Font("Tahoma", Font.BOLD, 12));
                
                cb = new JComboBox();
                cb.setModel(new DefaultComboBoxModel(new String[] {"None", "Bare Bones", "Meager", "Normal", "Well-Fed"}));
                
                cb2 = new JComboBox();
                cb2.setModel(new DefaultComboBoxModel(new String[] {"Stopped", "Leisurely", "Steady", "Grueling"}));
                
                ok = new JButton("Start Roadtrip");
                
                GroupLayout gl_contentPane = new GroupLayout(this);
                gl_contentPane.setHorizontalGroup(
                        gl_contentPane.createParallelGroup(Alignment.LEADING)
                                .addGroup(gl_contentPane.createSequentialGroup()
                                        .addContainerGap()
                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                                                .addGroup(gl_contentPane.createSequentialGroup()
                                                        .addComponent(lblRations)
                                                        .addPreferredGap(ComponentPlacement.UNRELATED)
                                                        .addComponent(cb, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                                .addGroup(gl_contentPane.createSequentialGroup()
                                                        .addComponent(lblPace, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap(ComponentPlacement.UNRELATED)
                                                        .addComponent(cb2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
                                        .addContainerGap(330, Short.MAX_VALUE))
                                .addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
                                        .addContainerGap(314, Short.MAX_VALUE)
                                        .addComponent(ok)
                                        .addGap(21))
                );
                gl_contentPane.setVerticalGroup(
                        gl_contentPane.createParallelGroup(Alignment.LEADING)
                                .addGroup(gl_contentPane.createSequentialGroup()
                                        .addGap(60)
                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                                .addComponent(lblRations)
                                                .addComponent(cb, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                        .addGap(18)
                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                                .addComponent(lblPace)
                                                .addComponent(cb2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                        .addGap(92)
                                        .addComponent(ok)
                                        .addContainerGap(19, Short.MAX_VALUE))
                );
                setLayout(gl_contentPane);
        }
        /**
         * This method adds the actionListener to the OK button
         * @param al
         */
        public void addOKListener(ActionListener al)
        {
                ok.addActionListener(al);
        }
        /**
         * This is the getter for the ration index
         * @return
         */
        public int getRationIndex()
        {
                return cb.getSelectedIndex();
        }
        /**
         * This is the getter for the pace index
         * @return
         */
        public int getPaceIndex()
        {
                return cb2.getSelectedIndex();
        }
        /**
         * This is the setter for the OK button listener
         * @param lbl
         */
        public void setOkBtnLbl(String lbl)
        {
                ok.setText(lbl); 
        }
}
